import {GET, POST} from "@/api/network";

export module Api {
    export module Clean {


        export interface GetKeywordsRequest {
            star_id:string
        }

        export interface GetKeywordsResponse_Item {
            keyword_id:string
            keyword:string
        }

        export interface GetKeywordsResponse {
            items: Array<GetKeywordsResponse_Item>
        }

        export function GetKeywords(ask: GetKeywordsRequest) : Promise<GetKeywordsResponse> {
            return GET(
                `/clean/keywords/${ask.star_id}`
            )
        }


        export interface EnableCleanRequest {
            star_id:string
        }

        export interface  EnableCleanResponse {

        }


        export function EnableClean(ask: EnableCleanRequest) : Promise<EnableCleanResponse> {
            return GET(
                `/clean/enable/${ask.star_id}`
            )
        }


        export interface AddKeywordRequest {
            star_id:string
            keyword:string
        }
        
        export interface AddKeywordResponse {

        }

        export function AddKeyword(ask: AddKeywordRequest) : Promise<AddKeywordResponse> {
            return POST(
                `/clean/keyword/add`,
                ask,
            )
        }


        export interface GetWordListResponse_Word {
            word_id:string
            word:string
            index:number
            score:number
            selected:boolean
        }

        export interface GetWordListResponse_Keyword {
            keyword_id:string
            keyword:string
            words:Array<GetWordListResponse_Word>
        }

        export interface GetWordListResponse {
            keywords:Array<GetWordListResponse_Keyword>
        }

        export interface GetWordListRequest {
            star_id:string
        }

        export function GetWordList(ask:GetWordListRequest) : Promise<GetWordListResponse> {
            return GET(
                `/clean/word/list/${ask.star_id}`
            )
        }
        
        
        /*
        type Location struct {
		Index int32 `json:"index"`
		Score int64 `json:"score"`
	}

	type Item struct {
		WordID     string    `json:"word_id"`
		ClubID     string    `json:"club_id"`
		ClubName   string    `json:"club_name"`
		ClubIcon   string    `json:"club_icon"`
		Word       string    `json:"word"`
		Now        *Location `json:"now"`
		History    *Location `json:"history"`
		CreateTime time.Time `json:"create_time"`
	}
         */

        export interface GetCleanWordListRequest {
            star_id:string
        }
        
        export interface GetCleanWordListResponse_History {
            index:number
            score:number
        }

        export interface GetCleanWordListResponse_Item {
            word_id:string
            club_id:string
            club_name:string
            club_icon:string
            word:string
            now:GetCleanWordListResponse_History
            history:GetCleanWordListResponse_History
            create_time:string

            //extend
            score_status:number
            index_status:number

            score_up:number|string
            index_up:number|string

        }

        export interface GetCleanWordListResponse {
            items:Array<GetCleanWordListResponse_Item>
        }

        export function GetCleanWordList(ask: GetCleanWordListRequest) : Promise<GetCleanWordListResponse> {
            return GET(
                `/clean/words/tasks/${ask.star_id}`
            )
        }
        
        export interface RemoveCleanClubWordRequest {
            word_id:string
            club_id:string
            star_id:string
        }

        export interface RemoveCleanClubWordResponse {

        }

        export function RemoveCleanClubWord(ask: RemoveCleanClubWordRequest) : Promise<RemoveCleanClubWordResponse> {
            return POST(
                `/clean/club/word/club/${ask.club_id}`,
                ask
            )
        }

        export interface RemoveKeywordRequest {
            star_id:string
            keyword_id:string
        }

        export interface RemoveKeywordResponse {

        }
        export function RemoveKeyword(ask:RemoveKeywordRequest) : Promise<RemoveKeywordResponse> {
            return POST(
                `/clean/club/keyword/delete`,
                ask,
            )
        }
    }
}

export default Api.Clean